/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 *
 */
import { TaskNames } from './common/task-names.js';
import CommonTask = TaskNames.CommonTask;
import CommonHookTask = TaskNames.CommonHookTask;
import { AbstractModuleHookTask } from './hook/abstract-module-hook-task.js';
import { ModuleTaskService } from './service/module-task-service.js';
import { TargetTaskService } from './service/target-task-service.js';

export class GeneratedBuildProfileTask extends AbstractModuleHookTask {
  private readonly isHar: boolean = false;

  constructor(moduleService: ModuleTaskService, isHar: boolean) {
    super(moduleService, false, CommonHookTask.GENERATE_BUILD_PROFILE);
    this.isHar = isHar;
  }

  public initTaskDepends(taskTargetService: TargetTaskService) {
    if (this.isHar) {
      this.dependsOn(`${taskTargetService.getTargetData().getTargetName()}@${CommonTask.CREATE_HAR_BUILD_PROFILE.name}`);
    } else {
      this.dependsOn(`${taskTargetService.getTargetData().getTargetName()}@${CommonTask.CREATE_BUILD_PROFILE.name}`);
    }
  }
}
